<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/wlzz/css/font.css">
    <link rel="stylesheet" href="/wlzz/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="/wlzz/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/wlzz/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-body">
        <form  enctype="multipart/form-data" id="uploadForm"  method="post" >
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>轮播图
              </label>
              <div class="layui-input-inline">
                  <input type="file" id="banner_img" name="banner_img" required=""
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>将用于展示app的轮播图
              </div>
          </div>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  <span class="x-red">*</span>跳转链接
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="banner_url" name="banner_url" required=""
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>点击轮播图将跳转的地址
              </div>
          </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
              <a  class="layui-btn" id="submitButton">
                  增加轮播图
              </a>
            </div>
      </form>
    </div>
    <script>
        $("#submitButton").click(function() {
            var banner_url = $("#banner_url").val();
            var banner_img = $("#banner_img").val();
            if(banner_url==""){
                layer.msg("链接不能为空", {icon: 5});
                return;
            }
            if(banner_img==""){
                layer.msg("图片不能为空", {icon: 5});
                return;
            }
             var formData = new FormData($('#uploadForm')[0]);
             console.log(formData);
               $.ajax({
                    url:"/wlzz/backstage/addBanner",
                    type:"post",
                    data:formData,
                    processData:false,
                    contentType:false,
                    success:function(data){
                        console.log(data);
                        parent.location.replace("/wlzz/backstage/banner");
                        x_admin_close();
                        },
                    error:function(e){
                    }
                });

            });
    </script>

  </body>

</html>